﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NUnit.Framework;

namespace NHibernateTests.Tests
{
    [TestFixture]
    public class CreateDatabase : BaseNhibernateTestFixture
    {
        [TestFixtureSetUp]
        public override void FixtureSetup()
        {
            _RollBack = false;
            base.FixtureSetup();
        }
        [Test]        
        public void CreateSchema()
        {
            Configuration cfg = new NHibernate.Cfg.Configuration();
            SchemaExport exporter = new SchemaExport(cfg.Configure());
            exporter.Create(true, true);
            exporter.Execute(false, true, false, true);
        }

        [Test]
        public void PopulateDatabase()
        {
            Battlestar galactica = new Battlestar {
                Name = "Galactica",
                Engine = new Engine { KilaFooers = 20, KilaJitters = -9232 },
                ServiceDate = new DateTime(2040, 7, 4)
            };

            Battlestar pegasus = new Battlestar {
                Name = "Pegasus",
                Engine = new Engine { KilaFooers = 2139, KilaJitters = -1232 },
                ServiceDate = new DateTime(2051, 1, 20)
            };

            CurrentSession.Save(galactica);
            CurrentSession.Save(pegasus);
        }

        [Test]
        public void GetBattleSTar()
        {
            Console.Write(
                CurrentSession.Get<Battlestar>(1).Name
                );
        }
    }
}
